#ifndef H_RCGD_OFFSET_H
#define H_RCGD_OFFSET_H

#define OFFSET_WINDOW_SIZE 60

#define MODE_PHASEJUMP_BEFORE 0
#define MODE_PHASEJUMP_AFTER  1

typedef struct {
	double DATA[OFFSET_WINDOW_SIZE];
	double SumX;
	double SumXVar;
	double XMean;
	double SumY_Before;
	double SumY_After;
	double SumXDiffY_Before;
	double SumXDiffY_After;
	double Grad_Before;
	double YInt_Before;
	double Grad_After;
	double YInt_After;
	double Offset;
	double Offset_Sum;
	double YValue_Before;
	double YValue_After;
	int    Counter;
	int    PosEnd;
	int    Calc_Index;
	int    Over8E6;

	int	   Phase_Jump_Index;
	int    Offset_Add_Flag;
}Offset_2nd_;

extern void Push_Offset_2nd(double Data);
extern double Pop_Offset_2nd(void);
extern void Init_Offset_2nd(void);
extern void Calc_Grad_YInt(char mode);
extern void IsOver8E6(void);
extern void Calc_Offset_2nd(void);

extern Offset_2nd_ Offset_2nd;
extern char func_PhaseJump_After;
extern char func_PhaseJump_Before;
extern char func_Calc_Offset_2nd;


extern char PhaseJump_EVENT;
extern int  PhaseJump_Counter;


extern double gSumY_Before;
extern double gSumXDiffY_Before;
extern double gSumY_After;
extern double gSumXDiffY_After;
extern double gOutputData_Before_Offset;

#endif

